<template>
	<view id="notice-list">
		<view class="list-view">
			<view class="list-li"  v-for="(list,index) in newsList" :key="index" @click="toNoticeDetail(list.id)">
				<view class="title">{{list.title}}</view>
				<view class="content">
					<view class="time">{{list.create_time}}</view>
					<view class="opt">查看详情<uni-icons class="row-icon" type="arrowright" color="#FF5001" size="16"></uni-icons></view>
				</view>
			</view>
			<view class="no-data-tips" v-if="newsList.length == 0">
				<image class="no-data-img" src="../../static/img/no-data-img.png" mode=""></image>
				<view>暂无数据</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		apiGetPushMessageList
	} from '../../../http/apis.js'
	
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState(['token'])
		},
		data(){
			return{
				newsList: [],
				allNum: 0
			}
		},
		onShow() {
			this.getNewsList()
		},
		onLoad() {
			
		},
		methods:{
			getNewsList(){
				apiGetPushMessageList({
					token: this.token,
					page: 1,
					pageSize: 999
				}).then(res =>{
				    if(res.data.code == 1)  {
						this.newsList = res.data.msg.res
						this.allNum = res.data.msg.allNum;
					}         
				}).catch(res => {
					this.$msg.showToast(res.data.msg)
				})
			},
			toNoticeDetail(id){
				uni.navigateTo({
					url: './noticeDetail?id=' + id + '&type=2'
				});
			}
			
		}
	}
</script>

<style lang="scss">
	page{
		background: #F5F5F5;
	}
	#notice-list{
		.list-view {
			.list-li {
				background: #FFFFFF;
				margin: 32upx 32upx 0 32upx;
				padding: 32upx 32upx 20upx 32upx;
				border-radius: 24upx;
				.title {
					font-size: 30upx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 42upx;
				}
				.content {
					display: flex;
					justify-content:space-between;
					align-items: center;
					.time {
						font-size: 26upx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						line-height: 24upx;
					}
					.opt {
						font-size: 28upx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: $theme-color;
						line-height: 40px;
					}
				}
			}
		}
		.no-data-tips {
			text-align: center;
			font-size: 28upx;
			font-weight: 400;
			color: #999999;
			line-height: 28upx;
			.no-data-img {
				width: 300upx;
				height: 300upx;
				margin-top: 200upx;
				margin-bottom: 20upx;
			}
		}
	}
</style>
